#-----------------------------------[知乎：叶枝黎曼]----------------------------
from itertools import permutations
n = int(input())
s = [i for i in range(1,n+1)]
for var in permutations(s):
    print(' '.join(map(str,var)))
